A few bits of N2994 didn't get fully implemented a long time ago. Thanks to STL@microsoft.com for the bug report git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@235134 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/ratio b/include/ratio index 48dcd81..25ab503 100644 --- a/include/ratio +++ b/include/ratio
@@ -21,8 +21,8 @@ class ratio { public: - static const intmax_t num; - static const intmax_t den; + static constexpr intmax_t num; + static constexpr intmax_t den; typedef ratio<num, den> type; }; @@ -236,13 +236,13 @@ static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range"); static_assert(_Den != 0, "ratio divide by 0"); static_assert(__static_abs<_Den>::value > 0, "ratio denominator is out of range"); - static const intmax_t __na = __static_abs<_Num>::value; - static const intmax_t __da = __static_abs<_Den>::value; - static const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value; - static const intmax_t __gcd = __static_gcd<__na, __da>::value; + static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>::value; + static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>::value; + static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value; + static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>::value; public: - static const intmax_t num = __s * __na / __gcd; - static const intmax_t den = __da / __gcd; + static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd; + static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd; typedef ratio<num, den> type; };